const path = require("path");

module.exports = {
    filePath: path.join(__dirname, '../../dynamic.yml'),
    nacosApi: {
        baseUrl: 'http://192.168.31.101:8848/nacos/v1/ns',
        // baseUrl: 'http://192.168.31.101:8848/nacos/v3/admin/ns',

        apiList: {
            instanceInfo: '/instance/list',
            serviceList: '/service/list',
        }
    },
    nacosConfig: {
        nameSpace: 'public',
    },
    // 每隔五秒检查一下最新配置
    check_time: 10000,
    // traefik 通用中间件配置
    traefikConfig: {
        middlewaresStr: ['compress', 'ipWhiteList', 'rateLimit', 'retries'],
        middlewaresConfig: {
            // 限流中间件
            rateLimit: {
                rateLimit: {
                    average: 100,
                    burst: 200,
                    period: '1s',
                    sourceCriterion: {
                        ipStrategy: {depth: 2}
                    }
                }
            },
            // 压缩中间件
            compress: {
                compress: {
                    excludedContentTypes: ['text/event-stream'],
                    minResponseBodyBytes: 1024
                }
            },
            // IP白名单中间件
            ipWhiteList: {
                ipWhiteList: {
                    sourceRange: ['127.0.0.1/32', '192.168.107.0/24']
                }
            },
            // // 重定向中间件（HTTP→HTTPS）
            // redirectToHttps: {
            //     redirectScheme: {
            //         scheme: 'https',
            //         permanent: true
            //     }
            // },
            // 重试中间件（关键修复：将重试配置移到这里）
            retries: {
                retry: {
                    attempts: 3,
                    initialInterval: '200ms'
                }
            }
        }
    }
}